package com.hyx.bookManager.config;

import com.hyx.bookManager.adapter.AdminInterceptor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @ClassName InterceptorConfig
 * @Description TODO
 * @Author 黄乙轩
 * @Date 2021/6/7 22:33
 * @Version 1.0
 **/

@Configuration
public class LoginConfig implements WebMvcConfigurer {

    @Bean
    public AdminInterceptor getAdminInterceptor(){
        return new AdminInterceptor();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        InterceptorRegistration registration = registry.addInterceptor(getAdminInterceptor());
        registration
                .addPathPatterns("/admin**/**");
    }
}
